#include <iostream>
#include <QtGui>
#include "dialogs.h"
#include "ui_datachanged_dialog.h"

DataChangedDialog::DataChangedDialog(QWidget *parent) : QDialog(parent) 
{
    setupUi(this);
    this->setAttribute(Qt::WA_DeleteOnClose);
    //connect(this, SIGNAL(clicked(QAbstractButton*)), this, SLOT(on_buttonBox_clicked(QAbstractButton*)));
}

DataChangedDialog::~DataChangedDialog() {
}

int DataChangedDialog::get_clicked_button()
{
    return clicked_button;
}

void DataChangedDialog::on_buttonBox_clicked(QAbstractButton *button) {
    switch(this->buttonBox->buttonRole(button)) {
      case QDialogButtonBox::YesRole:
	std::cout << "Yes" << "\n";
	clicked_button = DialogReturn_YES;
	this->done(DialogReturn_YES);
	close();
	break;
      case QDialogButtonBox::NoRole:
	clicked_button = DialogReturn_NO;
	this->done(DialogReturn_NO);
	close();
	std::cout << "No" << "\n";
	break;
      case QDialogButtonBox::RejectRole:
	clicked_button = DialogReturn_CANCEL;
	this->done(3);
	close();
	std::cout << "Cancel" << "\n";
	break;
    }
    std::cout.flush();
}

#include "dialogs.moc"